<?php
$n=0;
$array=array('cust_first_name','cust_last_name','cust_tax_code','cust_address','cust_phone','cust_email','cust_dob','cust_bank_account','cust_cmnd','cust_cmnd_date','cust_cmnd_images','cust_sex');
foreach($array as $v){
	if($this->data["result"][$v]!=""){
		$n+=1;
	}
}
$color="danger";
$px=round($n/(count($array))*100);
?>
<section class="vbox" id="detail_customer">
	<section class="scrollable">
		<section class="hbox stretch">
			<aside class="col-lg-6 bg-light lter b-r">
				<section class="vbox">
					<section class="scrollable">
						<div class="wrapper">
							<section class="panel no-border bg-bla lt">
								<div class="panel-body">
									<div class="row m-t-xl">
										<div class="col-xs-12 text-center">
											<div class=""><!-- inline -->
												<div  style="width: 140px; height: 140px; line-height: 140px;margin: 0 auto;">
													<div class="thumb-lg avatar">
														<img src="/salesupport/images/avatar.png" class="dker">
													</div>
													<canvas width="140" height="140"></canvas>
													<input type="hidden" value="<?php echo $_REQUEST["id"]?>" id="cust_id"/>
												</div>
												<div class=" col-xs-6 h4 m-t m-b-xs font-bold text-lt  pointer editable editable-click text-right"   id="dt_first_name" style="padding-right: 5px;" data="cust_first_name">
													<?php echo $this->data["result"]["cust_first_name"];?>
												</div>
												<div class=" col-xs-6 h4 m-t m-b-xs font-bold text-lt  pointer editable editable-click text-left"  id="dt_last_name" style="padding-left: 5px;" data="cust_last_name">
													<?php echo $this->data["result"]["cust_last_name"];?>
												</div>
												<small class="text-muted m-b pointer editable editable-click"  id="dt_address" data="cust_address">
													<?php echo $this->data["result"]["cust_address"];?>
												</small>
											</div>
										</div>
									</div>
									<div class="wrapper m-t m-b">
										<input type="hidden" id="comp_id" value="">
										<div class="row m-b">
											<div class="col-xs-6 text-right " > <small>Công ty</small>

												
											<div class="text-lt font-bold">
													<?php foreach($this->data["result_comp"] as $value){
														?>
														<a href="<?php echo base_url()?>/companies/detail?id=<?php echo $value["comp_id"]?>" class=" pointer"><?php echo $value["comp_name"]?></a><br/>
														<?php 
													}
													?>

													
												</div>
											</div>
											<div class="col-xs-6 text-left pointer  "> <small>Ngày sinh</small>
												<div class="text-lt font-bold editable"  id="dt_dob" data-type="date" data="cust_dob"  data-type="date" ><?php echo $this->data["result"]["cust_dob"];?></div>
											</div>
										</div>
										<div class="row m-b">
											<div class="col-xs-6 text-right  pointer  " > <small>Điện thoại</small>
												<div class="text-lt font-bold editable"  id="dt_phone" data="cust_phone"><?php echo $this->data["result"]["cust_phone"];?></div>
											</div>
											<div class="col-xs-6 text-left pointer  "> <small>Email</small>
												<div class="text-lt font-bold editable"  id="dt_email" data="cust_email"><?php echo $this->data["result"]["cust_email"];?></div>
											</div>
										</div>

										<div class="row m-b">
											<div class="col-xs-6 text-right  pointer  " > <small>CMND</small>
												<div class="text-lt font-bold editable"  id="dt_phone" data="cust_cmnd">
												<?php echo $this->data["result"]["cust_cmnd"];?></div>
											</div>
											<div class="col-xs-6 text-left pointer  "> <small>Ngày Cấp CMND</small>
												<div class="text-lt font-bold editable"  id="dt_email" data="cust_cmnd_date"  data-type="date" ><?php echo $this->data["result"]["cust_cmnd_date"];?></div>
											</div>
										</div>

										<div class="row m-b">
											<div class="col-xs-6 text-right  pointer " > <small>Tài khoản ngân hàng</small>
												<div class="text-lt font-bold editable"  id="dt_phone" data="cust_bank_account" data-type="textarea" ><?php echo $this->data["result"]["cust_bank_account"];?></div>
											</div>
											<div class="col-xs-6 text-left pointer  "> <small></small>
												<div class="text-lt font-bold "  id="dt_email" data="cust_cmnd_date"></div>
											</div>
										</div>

										<div class="row m-t-lg">
											<div class="col-xs-6 col-xs-offset-3 text-center">
												<small>Tình trạng</small>
												<div class="text-lt font-bold">
													<?php if($this->fclass->check_permission('special','is_accounting',$this->session->userdata('permissions2'),$this->session->userdata('permissions_base'))){
														?>
														<form action="" method="POST" class="form_verify">
															<input type="hidden" name="mod" value="verify">
															<?php 
															if($this->data["result"]["cust_status"]==-2){
																echo '<button type="button" onclick="viewMsg(\'Khách hàng này đang chờ Sale Quản Lý Xử lý\')" class="btn btn-warning btn-s-lg">Đang bị confLict</button>';
															}else if($this->data["result"]["cust_status"]==0){
																if($px<100){
																	echo '<button type="button" onclick="viewMsg(\'Vui lòng cập nhật đầy đủ thông tin mới được xác nhận.<br/> Thông tin đang đã được cập nhật '.$px.'%\')" class="btn btn-danger btn-s-lg">Chưa xác nhận</button>';
																}else{
																	echo '<button type="button" onclick="validate_verify()" class="btn btn-danger btn-s-lg">Chưa xác nhận</button>';
																}

															}else if($this->data["result"]["cust_status"]==1){
																echo '<button type="button" class="btn btn-primary btn-s-lg">Đã Xác Nhận</button>';
															}else{

															}
															?>
														</form>
														<?php }else{
															if($this->data["result"]["cust_status"]==-2){
																echo '<span class="label bg-warning">Đang bị confLict</span>';
															}else if($this->data["result"]["cust_status"]==0){
																
																echo '<span class="label bg-danger btn-s-lg">Chưa xác nhận</span>';
																

															}else if($this->data["result"]["cust_status"]==1){
																echo '<span class="label bg-success">Đã Xác Nhận</span>';
															}else{

															}

														}?>
													</div>
												</div>
											</div>
											

										</div>
									</div>
									<footer class="panel-footer dk text-center no-border">
										<div class="row pull-out">
											<div class="col-xs-4">
												<div class="padder-v"> <span class="m-b-xs h3 block text-white">---</span>  <small class="text-muted"></small>
												</div>
											</div>
											<div class="col-xs-4 dker">
												<div class="padder-v"> <span class="m-b-xs h3 block text-white">---</span>  <small class="text-muted"></small>
												</div>
											</div>
											<div class="col-xs-4">
												<div class="padder-v"> <span class="m-b-xs h3 block text-white">---</span>  <small class="text-muted"></small>
												</div>
											</div>
										</div>
									</footer>
								</section>
								<h4 class="padder"> Công việc</h4>
								<div class="wrapper">
									<section class="comment-list block">
										<?php 
										foreach($this->data["feed_result"] as $value){
											?>
											<article id="comment-id-3" class="comment-item">
												<a class="pull-left thumb-sm avatar">
													<img src="<?php echo base_url()?>images/un-avatar.png">
												</a> <span class="arrow left"></span>
												<section class="comment-body panel panel-default">
													<header class="panel-heading"> <a href="#"><strong><?php echo $value["uFullname"] ?></strong></a>

														gặp khách hàng <a href="<?php echo base_url()?>customer/detail?id=<?php echo $value["cust_id"]?>" title="sdasdas đâsd" class="label bg-warning m-l-xs"><?php echo $value["cust_first_name"]." ".$value["cust_last_name"]; ?></a> <span class="text-muted m-l-sm pull-right"> <i class="fa fa-clock-o"></i> <?php echo @date("d-m-Y h:i:s",$value["feed_action_time"]); ?></span>
													</header>
													<div class="panel-body">
														<div  class="col-xs-12"><?php echo $value["feed_content"]?></div>
													</div>
												</section>
											</article>
											<?php
										}
										?>

									</section>
									<section class="chat-list block">
										<article class="chat-item left">
											<div class="col-lg-12 text-center">
												<ul class="pagination pagination">
													<?php 
													
													$config_cust['base_url'] = base_url().'customer/detail?id='.$_REQUEST["id"];
													$config_cust['total_rows'] = $this->data["feed_count_page"];
													$config_cust['page_query_string'] = TRUE;
													$config_cust['per_page'] = 10; 														
													$config_cust['full_tag_open'] = '<li>';
													$config_cust['full_tag_close'] = '</li>';
													$config_cust['last_tag_open'] = '<li>';
													$config_cust['last_tag_close'] = '</li>';
													$config_cust['next_tag_open'] = '<li>';
													$config_cust['next_tag_close'] = '</li>';
													$config_cust['prev_tag_open'] = '<li>';
													$config_cust['prev_tag_close'] = '</li>';
													$config_cust['cur_tag_open'] = '<li><a><b>';
													$config_cust['cur_tag_close'] = '</b></a></li>';
													$config_cust['num_tag_open'] = '<li>';
													$config_cust['num_tag_close'] = '</li>';
													$this->pagination->initialize($config_cust); 
													echo $this->pagination->create_links();
													
													?>

												</ul>
											</div>													
										</article>
									</section>
								</div>
							</div>
						</section>
					</section>
				</aside>
				<aside class="col-lg-6 b-l no-padder">
					<section class="vbox">
						<section class="scrollable">
							<div class="wrapper">
								<div class="msg-data"></div>
								<section class="panel panel-warning portlet-item">
									<header class="panel-heading">Hình ảnh CMND</header>
									<div class="row">
										<div class="col-lg-12">
											<ul class="list-inline" id="img_cmnd_result" style="padding: 15px 15px 0;">
												<?php
												$imageUpload = json_decode($this->data["result"]["cust_cmnd_images"],true);
												if(count($imageUpload)>0){
													foreach($imageUpload as $num=> $val){
														echo '<li class="im_cmnd_'.$num.'">
														<a href="'.$val.'" class="thumbnail fancybox"><img src="'.$val.'" style="width:150px;height:120px;"></a>
														<span class="img-remove" onclick="remove_img_cmnd('.$_REQUEST["id"].','.$num.');"><i class="fa fa-times"></i></span>
													</li>';
												}
											}										
											?>
										</ul>
									</div>
								</div>
								<div class="row">
									<div class="col-lg-11 col-lg-offset-1">
										<div id="img_cmnd"></div>
									</div>
								</div>
							</section>
							<?php 
							// QUYEN TRUONG PHONG SALE
							if($this->session->userdata('uType')==1){?>	
							<section class="panel-default">
								<header class="panel-heading" style="background:">Sale Đang Quản Lý</header>
									<section class="panel panel-default list-sale" id="progressbar">
										<header class="panel-heading">
											<div class="row m-t-sm">
												<div class="col-sm-8 m-b-xs">													
													<div class="btn-group">
														<button type="button" class="btn btn-sm btn-default" onclick="selectListSale(0)" title="Refresh"><i class="fa fa-refresh"></i></button>
														<button type="button" class="btn btn-sm btn-default" onclick="delectCustUser()" title="Remove"><i class="fa fa-trash-o"></i></button>
													</div>
													<a href="<?php echo base_url("customer/full_sale_view")?>" data-toggle="ajaxModal" class="btn btn-sm btn-default"><i class="fa fa-plus"></i> Thêm Sale Cho Khách Hàng</a> 
												</div>
												<div class="col-sm-4 m-b-xs">
													
														<div class="input-group"><input type="text" name="where" placeholder="Search" class="input-sm form-control" value="<?php echo $this->input->post('where')?>"> <span class="input-group-btn"> <button class="btn btn-sm btn-default" onclick="selectListSale(0)">Tìm!</button> </span> </div>
													
												</div>
											</div>
										</header>
										<table class="table table-striped table-condensed table-hover table-bordered">
											<thead>
												<tr>
													<th width="20"><label class="checkbox m-n i-checks"><input type="checkbox"><i></i></label></th>
													<th width="170">Họ tên</th>
													<th width="120">Số Điện Thoại</th>
													<th>Ngành Hàng</th>
													<th width="120">Thay Đổi Ngành Hàng</th>
												</tr>
											</thead>
											<tbody class="data-table">		


											</tbody>
										</table>
										<footer class="footer bg-white b-t">
										   <div class="row text-center-xs">
										      <div class="col-md-12 col-sm-12 text-center text-center-xs">
										         <ul class="paging-sale pagination pagination-sm m-t-sm m-b-none"></ul>
										      </div>
										   </div>
										</footer>
									</section>	
							</section>						
							<?php }?>															
						</div>

					</section>
				</section>
			</aside>

		</section>
	</section>
</section>

